#include "Objet3D.h"

Objet3D::Objet3D(IFile * f): Displayer(f)
{
    _pos[0] = _pos[1] = _pos[2] = 0;
    _cAngle[0] = _cAngle[1] = _cAngle[2] = 0;
}

void Objet3D::rotate(float angle, float * v)
{
    for(int i = 0; i < 3; i++)
		_cAngle[i] = v[i];
	_angle = angle;
    
}


void Objet3D::translate(float * p)
{
    for(int i = 0; i < 3; i++)
		_pos[i] = p[i];
    
}

void Objet3D::display()
{
    int taille = _file->getNbFaces();
    GLuint * f = _file->getFaces();
    glPushMatrix();
    
    glTranslated( _pos[0], _pos[1], _pos[2]);
    glRotated(_angle, _cAngle[0], _cAngle[1], _cAngle[2]);
    
    glVertexPointer(3, GL_FLOAT, 0, _file->getVertices());
    glDrawElements(GL_TRIANGLES,taille, GL_UNSIGNED_INT, f);
    
    glPopMatrix();
}
